package com.team11.server.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.team11.server.mapper.ClockInformationMapper;
import com.team11.server.pojo.ClockInformation;
import com.team11.server.pojo.dto.RespPageBean;
import com.team11.server.service.IClockInformationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDate;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author pjc
 * @since 2021-07-06
 */
@Service
public class ClockInformationServiceImpl extends ServiceImpl<ClockInformationMapper, ClockInformation> implements IClockInformationService {

    @Resource
    private ClockInformationMapper clockInformationMapper;
    /**
     * 获取门禁打卡记录
     * @param currentPage 当前页
     * @param size 条数
     * @param sNumber 学号
     * @param sName 学生姓名
     * @return RespPageBean
     */
    @Override
    public RespPageBean getAccessControl(Integer currentPage, Integer size,  LocalDate startTime,LocalDate endTime, String sNumber, String sName) {
        IPage<ClockInformation> page = new Page(currentPage, size);
        IPage<ClockInformation> accessControl = clockInformationMapper.getAccessControl(page, startTime,endTime, sNumber, sName);
        return new RespPageBean(accessControl.getTotal(), accessControl.getRecords());
    }
    /**
     * 获取门禁打卡记录
     * @param currentPage 当前页
     * @param size 条数
     * @param sNumber 学号
     * @return RespPageBean
     */
    @Override
    public RespPageBean getStudentAccessControl(Integer currentPage, Integer size, LocalDate startTime,LocalDate endTime, String sNumber) {
        IPage<ClockInformation> page = new Page(currentPage, size);
        IPage<ClockInformation> studentAccessControl = clockInformationMapper.getStudentAccessControl(page, startTime,endTime, sNumber);
        return new RespPageBean(studentAccessControl.getTotal(), studentAccessControl.getRecords());
    }
}
